<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui"
      xmlns:h="http://java.sun.com/jsf/html">
<h:head>
    <meta http-equiv="Content-Type" content="application/xhtml+xml; charset=UTF-8"/>
    <title>#{msg.page_index}</title>

</h:head>
<h:body>


    <ui:decorate template="/sample.xhtml">
        <ui:define name="body">
            <h:form>
                <p:dataTable id="tbl" var="itemCar" value="#{car.cars}"
                             rows="6"
                             paginator="true"
                             paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown} {Exporters}"
                             rowsPerPageTemplate="5,10,15"
                             style="margin-bottom:20px"
                             widgetVar="carsTable"
                        >
                    <f:facet name="{Exporters}">
                        <h:commandLink id="excel">
                            <p:graphicImage name="image/exporter/excel.png.xhtml.png" />
                            <p:dataExporter type="xls" target="tbl" fileName="cars" postProcessor="#{car.postProcessXLS}" />
                        </h:commandLink>

                        <h:commandLink id="pdf">
                            <p:graphicImage name="image/exporter/pdf.png.xhtml.png" />
                            <p:dataExporter type="pdf" target="tbl" fileName="cars" preProcessor="#{car.preProcessPDF}" />
                        </h:commandLink>

                        <h:commandLink>
                            <p:graphicImage name="image/exporter/csv.png.xhtml.png" />
                            <p:dataExporter type="csv" target="tbl" fileName="cars" pageOnly="true" />
                        </h:commandLink>

                        <h:commandLink>
                            <p:graphicImage name="image/exporter/xml.png.xhtml.png" />
                            <p:dataExporter type="xml" target="tbl" fileName="cars" pageOnly="true" />
                        </h:commandLink>
                    </f:facet>


                    <p:column sortBy="#{itemCar.id}" filterBy="#{itemCar.id}">
                        <f:facet name="header">
                            <h:outputText value="Id" />
                        </f:facet>
                        <h:outputText value="#{itemCar.id}" />
                    </p:column>



                    <p:column sortBy="#{itemCar.transport.brand.nameEn}" filterBy="#{itemCar.transport.brand.nameEn}"   filterMatchMode="exact">
                        <f:facet name="header">
                            <h:outputText value="Brand" />
                        </f:facet>
                        <f:facet name="filter">
                            <p:selectOneMenu onchange="PF('carsTable').filter()" >
                                <f:selectItem itemLabel="Select One" itemValue="#{null}" noSelectionOption="true" />
                                <f:selectItems value="#{car.brands}" var="c" itemLabel="#{c.nameEn}" itemValue="#{c.nameEn}" />
                            </p:selectOneMenu>
                        </f:facet>
                        <h:outputText value="#{itemCar.transport.brand.nameEn}" />
                    </p:column>

                    <p:column sortBy="#{itemCar.model.nameEn}" filterBy="#{itemCar.model.nameEn}"   filterMatchMode="exact">
                        <f:facet name="header">
                            <h:outputText value="Model" />
                        </f:facet>
                        <f:facet name="filter">
                            <p:selectOneMenu onchange="PF('carsTable').filter()" >
                                <f:selectItem itemLabel="Select One" itemValue="#{null}" noSelectionOption="true" />
                                <f:selectItems value="#{car.models}" var="m" itemLabel="#{m.nameEn}" itemValue="#{m.nameEn}" />
                            </p:selectOneMenu>
                        </f:facet>
                        <h:outputText value="#{itemCar.model.nameEn}" />
                    </p:column>

                    <p:column filterBy="#{itemCar.transport.color.nameEn}" headerText="Color" filterMatchMode="in">
                        <f:facet name="filter">
                            <p:selectCheckboxMenu label="Colors" onchange="PF('carsTable').filter()" panelStyle="width:125px" scrollHeight="150">
                                <f:selectItems value="#{car.colors}" var="col" itemLabel="#{col.nameEn}" itemValue="#{col.nameEn}" />
                            </p:selectCheckboxMenu>
                        </f:facet>
                        <h:outputText value="#{itemCar.transport.color.nameEn}" />
                    </p:column>

                    <p:column sortBy="#{itemCar.transport.price}" filterBy="#{itemCar.transport.price}">
                        <f:facet name="header">
                            <h:outputText value="Price" />
                        </f:facet>
                        <h:outputText value="#{itemCar.transport.price}">
                            <f:convertNumber type="currency" currencySymbol="$"/>
                        </h:outputText>
                    </p:column>
                    <p:column sortBy="#{itemCar.transport.date}" filterBy="#{itemCar.transport.date}">
                        <f:facet name="header">
                            <h:outputText value="Date" />
                        </f:facet>
                        <h:outputText value="#{itemCar.transport.date}" >
                            <f:convertDateTime pattern="yyyy" />
                        </h:outputText>
                    </p:column>



                </p:dataTable>


            </h:form>
        </ui:define>
    </ui:decorate>










</h:body>
</html>


